
class Helper_diskSpaceManager(object):
    '''
    Es una clase fundamentalmente informativa.
    Aunque referida a un disco en particular, a un 
    FS particular por lo que no aplica SINGLETON.
    '''

    def __init__(self,aDisk):
        self.disk = aDisk
        self.freeBlocks = []
        self.freeInodes = []
        self.startUpSetFreeBlocks()
        self.startUpFreeInodes()
    
    def startUpSetFreeBlocks(self):
        self.freeBlocks = self.disk.getDataBlockKeys()
        
    
    def startUpFreeInodes(self):
        self.freeInodes = self.disk.getInodeKeys()
               
        
    def hayFreeBlocks(self):
        return not len(self.freeBlocks) == 0
        
    def hayNFreeBlocks(self,blockCant=0):
        return len(self.freeBlocks) >= blockCant
        
        
    def pickNFreeBlocks(self,blockCant):
        blockList = []
        for i in range (blockCant):
            blockList.append(self.pickFreeBlock())
    
        return blockList
            
    
    def pickFreeBlock(self):
        block = self.freeBlocks.pop(0)
        return block
    
    def hayFreeInodes(self):
        return (not (len(self.freeBlocks) == 0))
        
    def pickFreeInode(self):
        inode = self.freeInodes.pop(0)
        return inode
        
    

